import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { SecTimer } from "../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../com/gengine/core/frame/TimerType";
type int = number;
//class AwardsRightInfo
    
    export  class AwardsRightInfo extends View
    {
        constructor()
        {
            super();
            this.initComponent();
            return;
        }

        /* internal  */initComponent(): void
        {
            this._conditionTxt = ObjCreate.createTextField("", 10, 53, 260, 20, this);
            this._openCount = ObjCreate.createTextField("", 180, 102, 220, 40, this);
            this._rule1 = ObjCreate.createTextField("", 8, 178, 300, 20, this);
            this._rule2 = ObjCreate.createTextField("", 8, 198, 300, 40, this);
            this._rule3 = ObjCreate.createTextField("", 8, 232, 300, 80, this);
            this._rule1.htmlText = Language.getString(100007);
            this._rule2.htmlText = Language.getString(100008);
            this._rule3.htmlText = Language.getString(100009);
            var loc1;
            this._rule3.mouseWheelEnabled = loc1 = false;
            this._rule2.mouseWheelEnabled = loc1 = loc1;
            this._rule1.mouseWheelEnabled = loc1;
            this._getCondition = new Object /* flash.display.Bitmap */();
            this._getCondition.x = 20;
            this._getCondition.y = 20;
            addChild(this._getCondition);
            this._startCount = new Object /* flash.display.Bitmap */();
            this._startCount.x = 88;
            this._startCount.y = 105;
            addChild(this._startCount);
            this._startRule = new Object /* flash.display.Bitmap */();
            this._startRule.x = 10;
            this._startRule.y = 150;
            addChild(this._startRule);
            LoaderHelp.addResCallBack(ResFileConst.luckAwards, this.onResLoaded);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._getCondition.bitmapData = GlobalClass.getBitmapData(ImagesConst.luckGetCondition);
            this._startRule.bitmapData = GlobalClass.getBitmapData(ImagesConst.luckOpenRule);
            this._startCount.bitmapData = GlobalClass.getBitmapData(ImagesConst.luckOpenCount);
            return;
        }

        /* internal  */updateLeftTime(arg1: int): void
        {
            if (this._secTimer) 
            {
                this._secTimer.reset();
                this._secTimer.repeatCount = arg1;
            }
            else 
            {
                this._secTimer = new SecTimer(1, arg1);
            }
            this._secTimer.start();
            this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimeChange);
            return;
        }

        /* internal  */onTimeChange(arg1: SecTimer): void
        {
            var loc1=arg1.repeatCount;
            if (loc1 >= 0) 
            {
                this.showLeftTime(loc1);
            }
            return;
        }

        /* internal  */showLeftTime(arg1: int): void
        {
            var loc1=Math.floor(arg1 % 3600 / 60);
            var loc2=String(loc1);
            this._conditionTxt.htmlText = Language.getStringByParam(100003, loc2);
            return;
        }

        public setText(arg1: int, arg2: int, arg3: int): void
        {
            this._conditionTxt.visible = true;
            if (arg1 != 3) 
            {
                if (this._secTimer) 
                {
                    this._secTimer.stop();
                }
                this._conditionTxt.htmlText = Language.getStringByParam(100000 + arg1, String(arg2), String(arg3));
            }
            else if (arg3 * 60 > 0) 
            {
                this.updateLeftTime(arg3 * 60);
            }
            return;
        }

        public set openCount(arg1: int)
        {
            this._openCount.htmlText = "<font color=\'#00ff00\'size=\'20\'>" + String(arg1) + "</font>";
            return;
        }

        public removeText(): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            this._conditionTxt.htmlText = "";
            this._conditionTxt.visible = false;
            return;
        }

        /* internal */ /* var */_getCondition: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_startRule: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_startCount: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_conditionTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_openCount: Object /* flash.text.TextField */;

        /* internal */ /* var */_rule1: Object /* flash.text.TextField */;

        /* internal */ /* var */_rule2: Object /* flash.text.TextField */;

        /* internal */ /* var */_rule3: Object /* flash.text.TextField */;

        /* internal */ /* var */_secTimer: SecTimer;
    }
